package com.yunyan.util.predict;

public class LevelRatioAdjustment {
    public static int[] adjust(int[] X0) {
       // int[] X0 = {680, 670, 655};
        int j = 1;
        boolean b;

        while (true) {
            int[] YO = new int[X0.length];
            // 创建新的原始数列YO
            for (int i = 0; i < X0.length; i++) {
                YO[i] = X0[i] + j;
            }

            b = true; // 假设当前j值下的级比检验通过
            for (int m = 0; m < YO.length - 1; m++) {
                double l = (double) YO[m] / YO[m + 1];
                if (!(l > Math.exp(-2.0 / (X0.length + 1)) && l < Math.exp(2.0 / (X0.length + 1)))) {
                    b = false;
                    break;
                }
            }

            if (b) {
                for (int i = 0; i < YO.length; i++) {
                    System.out.print(YO[i] + (i < YO.length - 1 ? ", " : ""));
                }
                int c = j - 1;
                return YO;
            } else {
                j++;
            }
        }
    }
}

